package com.dengyuanke.common.log.event;

import com.dengyuanke.common.core.constant.SecurityConstants;
import com.dengyuanke.upms.domain.entity.Log;
import com.dengyuanke.upms.domain.feign.RemoteLogService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: dyk
 * Create time: 2019-07-13  11:36
 */
@Slf4j
@AllArgsConstructor
public class SysLogListener {

    @Autowired
    private RemoteLogService remoteLogService;

    @Async
    @EventListener
    public void saveSysLog(SysLogEvent event) {
        Log log = event.getLog();
        remoteLogService.saveLog(log, SecurityConstants.FROM_IN);
    }
}
